<!DOCTYPE html>
<script src="../../resources/run-after-layout-and-paint.js"></script>
<svg>
  <defs>
    <rect id="r" width="100" height="100" fill="green"/>
  </defs>
  <use xlink:href="foo#r"/>
</svg>
<script>
runAfterLayoutAndPaint(function() {
  var use = document.querySelector('use');
  use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', 'foo#r');
  history.pushState(null, '', '/svg/foo');
}, true);
</script>
